package com.minimalist.lindi.controller;

import com.minimalist.common.config.mybatis.bo.PageResp;
import com.minimalist.common.entity.lindi.vo.tradeapplicationapprovefile.LindiTradeApplicationApproveFileVO;
import com.minimalist.common.entity.lindi.vo.tradeapplicationapprovefile.TradeApplicationApproveFileQueryVO;
import com.minimalist.common.response.R;
import com.minimalist.common.utils.Add;
import com.minimalist.common.utils.Update;
import com.minimalist.lindi.service.LindiTradeApplicationApproveFileService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.constraints.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 林地指标交易平台_交易申请审批文件控制器
 *
 * @author 11987
 */
@Validated
@RestController
@Tag(name = "林地指标交易平台_交易申请审批文件管理")
@RequestMapping("/lindi/tradeApplicationApproveFile")
public class LindiTradeApplicationApproveFileController{

    @Autowired
    private LindiTradeApplicationApproveFileService service;

    @PostMapping("/addTradeApplicationApproveFile")
    @Operation(summary = "添加交易申请审批文件")
    public R<?> addTradeApplicationApproveFile(
            @RequestBody @Validated(Add.class)
            LindiTradeApplicationApproveFileVO tradeApplicationApproveFileVO){
        service.addTradeApplicationApproveFile(tradeApplicationApproveFileVO);
        return R.ok();
    }

    @DeleteMapping("/deleteTradeApplicationApproveFileByApproveFileId")
    @Operation(summary = "删除交易申请审批文件 -> 根据审批文件ID删除")
    public R<?> deleteTradeApplicationApproveFileByApproveFileId(
            @RequestParam("approveFileId")
            @NotNull(message = "审批文件ID不能为空")
            @Parameter(name = "approveFileId", required = true, description = "审批文件ID")
            Long approveFileId){
        service.deleteTradeApplicationApproveFileByApproveFileId(
                approveFileId);
        return R.ok();
    }

    @PutMapping("/updateTradeApplicationApproveFileByApproveFileId")
    @Operation(summary = "修改交易申请审批文件")
    public R<?> updateTradeApplicationApproveFileByApproveFileId(
            @RequestBody @Validated(Update.class)
            LindiTradeApplicationApproveFileVO tradeApplicationApproveFileVO){
        service.updateTradeApplicationApproveFileByApproveFileId(
                tradeApplicationApproveFileVO);
        return R.ok();
    }

    @GetMapping("/getPageTradeApplicationApproveFileList")
    @Operation(summary = "查询交易申请审批文件列表(分页)")
    public R<PageResp<LindiTradeApplicationApproveFileVO>> getPageTradeApplicationApproveFileList(
            @RequestBody TradeApplicationApproveFileQueryVO queryVO){
        return R.ok(service.getPageTradeApplicationApproveFileList(queryVO));
    }

    @GetMapping("/getTradeApplicationApproveFileByApproveFileId/{approveFileId}")
    @Operation(summary = "根据审批文件ID查询交易申请审批文件")
    public R<LindiTradeApplicationApproveFileVO> getTradeApplicationApproveFileByApproveFileId(
            @PathVariable(value = "approveFileId")
            @NotNull(message = "审批文件ID不能为空")
            @Parameter(name = "approveFileId", description = "审批文件ID", required = true)
            Long approveFileId){
        return R.ok(service.getTradeApplicationApproveFileByApproveFileId(
                approveFileId));
    }
}